package com.hjxr.xmgl.web.controller;

import java.util.List;

import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.xmgl.web.domain.QuotaEarlyWarningInfos;
import com.hjxr.xmgl.web.service.IQuotaEarlyWarningInfosService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;


/**
 * 预警指标配置明细Controller
 *
 * @author hjxr
 * @date 2021-12-02
 */
@RestController
@RequestMapping("/system/infos")
public class QuotaEarlyWarningInfosController extends BaseController
{
    @Autowired
    private IQuotaEarlyWarningInfosService quotaEarlyWarningInfosService;

    /**
     * 查询预警指标配置明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:infos:list')")
    @GetMapping("/list")
    public TableDataInfo list(QuotaEarlyWarningInfos quotaEarlyWarningInfos)
    {
        startPage();
        List<QuotaEarlyWarningInfos> list = quotaEarlyWarningInfosService.selectQuotaEarlyWarningInfosList(quotaEarlyWarningInfos);
        return getDataTable(list);
    }

    /**
     * 导出预警指标配置明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:infos:export')")
    @Log(title = "预警指标配置明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QuotaEarlyWarningInfos quotaEarlyWarningInfos)
    {
        List<QuotaEarlyWarningInfos> list = quotaEarlyWarningInfosService.selectQuotaEarlyWarningInfosList(quotaEarlyWarningInfos);
        ExcelUtil<QuotaEarlyWarningInfos> util = new ExcelUtil<QuotaEarlyWarningInfos>(QuotaEarlyWarningInfos.class);
        return util.exportExcel(list, "infos");
    }

    /**
     * 获取预警指标配置明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:infos:query')")
    @GetMapping(value = "/{ewInfoId}")
    public AjaxResult getInfo(@PathVariable("ewInfoId") String ewInfoId)
    {
        return AjaxResult.success(quotaEarlyWarningInfosService.selectQuotaEarlyWarningInfosById(ewInfoId));
    }

    /**
     * 新增预警指标配置明细
     */
    @PreAuthorize("@ss.hasPermi('system:infos:add')")
    @Log(title = "预警指标配置明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QuotaEarlyWarningInfos quotaEarlyWarningInfos)
    {
        return toAjax(quotaEarlyWarningInfosService.insertQuotaEarlyWarningInfos(quotaEarlyWarningInfos));
    }

    /**
     * 修改预警指标配置明细
     */
    @PreAuthorize("@ss.hasPermi('system:infos:edit')")
    @Log(title = "预警指标配置明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QuotaEarlyWarningInfos quotaEarlyWarningInfos)
    {
        return toAjax(quotaEarlyWarningInfosService.updateQuotaEarlyWarningInfos(quotaEarlyWarningInfos));
    }

    /**
     * 删除预警指标配置明细
     */
    @PreAuthorize("@ss.hasPermi('system:infos:remove')")
    @Log(title = "预警指标配置明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ewInfoIds}")
    public AjaxResult remove(@PathVariable String[] ewInfoIds)
    {
        return toAjax(quotaEarlyWarningInfosService.deleteQuotaEarlyWarningInfosByIds(ewInfoIds));
    }
}
